package com.wyy.config;

import org.apache.shiro.spring.web.config.DefaultShiroFilterChainDefinition;
import org.apache.shiro.spring.web.config.ShiroFilterChainDefinition;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ShiroConfig {

    @Bean
    public ShiroFilterChainDefinition shiroFilterChainDefinition() {
        DefaultShiroFilterChainDefinition definition = new DefaultShiroFilterChainDefinition();
        definition.addPathDefinition("/doLogin", "anon");
        definition.addPathDefinition("/register", "anon");
        definition.addPathDefinition("/api/parkLot/**", "anon");
        definition.addPathDefinition("/**", "authc");
        return definition;
    }


    /**
     * spring 配置项管理
     */

//     @Bean
//    public DefaultWebSecurityManager securityManager(MyRealm myRealm) {
//        DefaultWebSecurityManager manager = new DefaultWebSecurityManager();
//        manager.setRememberMeManager(rememberMeManager());
//        manager.setCacheManager(cacheManager());
//        manager.setRealm(myRealm);
//        return manager;
//    }
//
//    public RedisManager redisManager() {
//        RedisManager redisManager = new RedisManager();
//        redisManager.setHost("127.0.0.1:6379");
//        // redisManager.setTimeout(timeout);
//        // redisManager.setPassword(password);
//
//        return redisManager;
//    }
//
//    public RedisCacheManager cacheManager() {
//        RedisCacheManager redisCacheManager = new RedisCacheManager();
//        redisCacheManager.setPrincipalIdFieldName("uid");
//        redisCacheManager.setRedisManager(redisManager());
//        return redisCacheManager;
//    }
//
//    public DefaultWebSessionManager sessionManager() {
//        DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
//        sessionManager.setSessionDAO(redisSessionDAO());
//        return sessionManager;
//    }
//
//
//    public RedisSessionDAO redisSessionDAO() {
//        RedisSessionDAO redisSessionDAO = new RedisSessionDAO();
//        redisSessionDAO.setRedisManager(redisManager());
//        return redisSessionDAO;
//    }

}
